/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.fee.service;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.fee.entity.OpenInvoice;
import com.jeeplus.modules.fee.mapper.OpenInvoiceMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 应开发票Service
 * @author weisong
 * @version 2017-09-22
 */
@Service
@Transactional(readOnly = true)
public class OpenInvoiceService extends CrudService<OpenInvoiceMapper, OpenInvoice> {

	public OpenInvoice get(String id) {
		return super.get(id);
	}
	
	public List<OpenInvoice> findList(OpenInvoice openInvoice) {
		return super.findList(openInvoice);
	}
	
	public Page<OpenInvoice> findPage(Page<OpenInvoice> page, OpenInvoice openInvoice) {
		return super.findPage(page, openInvoice);
	}
	
	@Transactional(readOnly = false)
	public void save(OpenInvoice openInvoice) {
		super.save(openInvoice);
	}
	
	@Transactional(readOnly = false)
	public void delete(OpenInvoice openInvoice) {
		super.delete(openInvoice);
	}

	// 更新核销金额和状态
	@Transactional(readOnly = false)
	public int updateVcaMoneyAndStatusById(@Param("vcaMoney") Double vcaMoney, @Param("status") Integer status,
										   @Param("id") String id) {
		return mapper.updateVcaMoneyAndStatusById(vcaMoney, status, id);
	}

	// 查询最大的单号和日期【用来生成单号】
	public OpenInvoice findInvoiceNoAndInvoiceDate() {
		return mapper.findInvoiceNoAndInvoiceDate();
	}

	//根据发票子表查询发票主表
	public List<OpenInvoice> findOpenInvoiceByInvoiceDetail(String id ){
		return mapper.findOpenInvoiceByInvoiceDetail(id);
	}
}